package com.example.yiwei.crm.json;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/3/9.
 */

public class ReasonJson {
    public static List<Map<String,String>> get(String result){
        List<Map<String,String>> list = new ArrayList<>();
        try {
            JSONObject object = new JSONObject(result);
            JSONArray array = object.getJSONArray("list");
            for (int i = 0;i<array.length();i++){
                JSONObject object1 = array.getJSONObject(i);
                Map<String,String> map = new HashMap<>();
                if (object1.has("CSK03")){
                    map.put("CSK03",object1.getString("CSK03"));
                }
                if (object1.has("CSK01")){
                    map.put("CSK01",object1.getString("CSK01"));
                }
                list.add(map);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return list;
    }
}
